package problems;

import interfaces.EulerProblemInterface;
import utility.ProblemSpecifics;

public class EulerProblem006 implements EulerProblemInterface {

	private ProblemSpecifics problemSpecifics;

	private static final int UPPER_BOUNDARY = 100;

	public EulerProblem006() {
		String problemText = "Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum.";
		problemSpecifics = new ProblemSpecifics(problemText);
	}

	public void solve() {
		long result = squareOfSumsUpToBoundary() - sumOfSquaresUpToBoundary();
		problemSpecifics.setResultAndMarkSolved(result);
	}

	private int squareOfSumsUpToBoundary() {
		int sum = 0;
		for (int i = 1; i <= UPPER_BOUNDARY; i++) {
			sum = sum + i;
		}
		return sum * sum;
	}

	private long sumOfSquaresUpToBoundary() {
		long sum = 0;
		for (int i = 1; i <= UPPER_BOUNDARY; i++) {
			sum = sum + i * i;
		}
		return sum;
	}

	public long reportResult() {
		return problemSpecifics.reportResult();
	}

	public ProblemStatus reportStatus() {
		return new ProblemStatus(problemSpecifics.isSolved());
	}

	public String stateTheProblem() {
		return problemSpecifics.stateTheProblem();
	}
}
